
from google.appengine.api import users

import models.Blog

__all__ = [
    'Visitor',
    'GUser',
    'Blogowner',
    'Admin',
    'getCurRole',
    'isVisitor',
    'isGUser',
    'isBlogowner',
    'isAdmin',
    ]

Visitor = 1
GUser = 2
Blogowner = 3
Admin = 4

def getCurRole(blogid):
    roles = []
    if isVisitor():
        roles.append(Visitor)
    if isGUser():
        roles.append(GUser)
    if isBlogowner(blogid):
        roles.append(Blogowner)
    if isAdmin():
        roles.append(Admin)
    return roles

def isVisitor():
    return True

def isGUser():
    return not (users.get_current_user() == None)

def isBlogowner(blogid):
    return models.Blog.is_current_user_blogowner(blogid)

def isAdmin():
    return users.is_current_user_admin()
